#ifndef PLAYBACKVIDEOWIDGET_H
#define PLAYBACKVIDEOWIDGET_H

#include <QWidget>
#include <ffmpegdecode.h>
#include <recvavpacket.h>
#include <QLabel>

class PlaybackVideoWidget : public QWidget
{
    Q_OBJECT
public:
    explicit PlaybackVideoWidget(QWidget *parent = nullptr);
    ~PlaybackVideoWidget();

    void paintEvent(QPaintEvent *event) override;

signals:

public slots:
    void handleStartPlay(qlonglong startTime, int cameraId, int channel); // 起始时间戳（毫秒）、摄像头id、通道号
    void handleInitCodecFinished();
    void handleGetOneFrame(QImage img);
    void handleUpdateBitRate(double bitRate);
    void stopPlay();

private:
    QString _jsonStr; // 要发给服务器的V字段（起始时间戳+终止时间戳+摄像头id+通道号）
    FFmpegDecode *_pFFmpegDecode;
    RecvAVPacket *_pRecvAVPacket;
    QThread *_pDecodeThread;
    QThread *_pRecvPktThread;
    shared_ptr<RingBuffer> _pSharedBuffer; // 播放窗口内部收包线程和解码线程共享的环形缓冲区
    QImage _image; // 当前窗口此刻要显示的画面
    QLabel _label;
};

#endif // PLAYBACKWIDGET_H
